let fs = require("fs");
let startTime = new Date().getTime();
for (let i = 1; i < 10000; i++) {
    fs.writeFileSync("./realbigSync.txt", "还行", { flag: "a" });
}
let endTime = new Date().getTime();
console.log("同步方式写入文件:" + (endTime - startTime));

let asyncStartTime = new Date().getTime();
let finishNum = 0;//异步完成的个数
for (let j = 0; j < 10000; j++) {
    fs.writeFile("./realbigAsync.txt", "一般般", { flag: "a" }, function (err) {

        finishNum++;
        if (finishNum == 10000) {
            let asyncEndTime = new Date().getTime();
            console.log("异步的耗时" + (asyncEndTime - asyncStartTime));
        }
      
    })
}